﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FWK.DataLayer.Base;
using CDB.Model.Tabelas;
using System.Data;

namespace CDB.DataLayer.Tabelas
{
    public class DLTabela:FwDLBase
    {
        #region Construtor
        public DLTabela(string pstrConnection,string pstrProvider)
        {
            
            this.objFwProvider = new FwProvider(pstrProvider, pstrConnection);  
        }
        #endregion


        #region Listar
        public Collection<Tabela> Listar()
        {
            Collection<Tabela> colTabela = new Collection<Tabela>();
            StringBuilder strQuery = new StringBuilder();
            strQuery.Append("SELECT NAME FROM SYSOBJECTS WHERE TYPE = 'U'");

            objFwCommand = new FwCommand(strQuery.ToString());

            IDataReader objIDataReader = this.objFwProvider.ExecuteReader(objFwCommand);

            while (objIDataReader.Read())
            {
                Tabela objTabela = new Tabela();
                objTabela.FromIDataReader(objIDataReader);
                colTabela.Add(objTabela);
            }

            return colTabela;
        }
        #endregion
    }
}
